/*!
 * Simplex Admin Template - Version 1.0
 *
 * Copyright 2011, Prosoftware.pl Dominik Cwiklik
 * @see http://www.prosoftware.pl/simplex-admin-template/
 * @license MIT http://www.opensource.org/licenses/mit-license.php
 *
 * Includes jQuery | http://jquery.com/ | Copyright 2011, John Resig | Dual licensed under the MIT or GPL Version 2 licenses.
 * Includes Uni-form | http://sprawsm.com/uni-form/ | Copyright (c) 2010, Dragan Babic | Released under the MIT License.
 * Includes Facebox | http://defunkt.io/facebox/ | Copyright (c) 2007/2008 Chris Wanstrath  | Released under the MIT License.
 *
 * Date: Fri Mar 25 00:29:24 2011
 */

$(document).ready(function(){
		
	// Variables
	var objMain = $('#container');

	// Show sidebar
	function showSidebar(){
		objMain.addClass('use-sidebar');
		$.cookie('sid-pref', 'use-sidebar', { expires: 30 });
	}

	// Hide sidebar
	function hideSidebar(){
		objMain.removeClass('use-sidebar');
		$.cookie('sid-pref', 'hidden', { expires: 30 });
	}

	$('#button-hide').click(function(){
		hideSidebar();
	});
	$('#button-show').click(function(){
		showSidebar();
	});
	
	// Sidebar separator
	var objSeparator = $('#separator');

	objSeparator.click(function(e){
		e.preventDefault();
		if ( objMain.hasClass('use-sidebar') ){
			hideSidebar();
		}
		else {
			showSidebar();
		}
	}).css('height', $('#sidebar #left-menu').outerHeight() + 'px');
	//.css('height', objSeparator.parent().outerHeight() + 'px');

	// Load preference
	if ( $.cookie('sid-pref') == 'hidden' ){
		objMain.removeClass('use-sidebar');
	}
	
});